﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>ComObjCreate()</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../css/default.css" rel="stylesheet" type="text/css">
</head>
<body>

<h1>ComObjCreate() <span class="ver">[AHK_L 53+]</span></h1>
<p>创建 COM 对象.</p>
<pre class="Syntax">ComObject := ComObjCreate(CLSID [, IID])</pre>

<h3>参数</h3>
<table class="info">
  <tr>
    <td>CLSID</td>
    <td>要创建的 COM 对象的 CLSID 或可读 Prog ID.</td>
  </tr>
  <tr>
    <td>IID</td>
    <td><span class="ver">[v1.0.96.00+]:</span> 对象支持的接口标识符.</td>
  </tr>
</table>

<h3>返回值</h3>
<p>如果产生了错误, 则返回空字符串.</p>
<p>如果指定了 IID, 则返回接口指针.使用指针结束时脚本通常必须调用 <a href="ObjAddRef.htm">ObjRelease</a>.</p>
<p>否则返回可以在脚本中使用的包装器对象.参见 <a href="../Objects.htm#SyntaxInvoke">调用对象</a>.</p>

<h3>相关</h3>
<a href="ComObjGet.htm">ComObjGet</a>, <a href="ComObjActive.htm">ComObjActive</a>, <a href="ComObjConnect.htm">ComObjConnect</a>, <a href="ComObjArray.htm">ComObjArray</a>, <a href="ComObjError.htm">ComObjError</a>, <a href="http://msdn.microsoft.com/en-us/library/dcw63t7z.aspx">CreateObject (MSDN)</a>

<h3>示例</h3>
<p>参见后面的论坛主题, 可以看到不断增长的示例列表:<a href="http://www.autohotkey.com/forum/topic61509.html">http://www.autohotkey.com/forum/topic61509.html</a>.</p>
<pre class="NoIndent">
ie := <b>ComObjCreate</b>("InternetExplorer.Application")
ie.Visible := true  <em>; 这个语句在 IE7 中无法正常执行.</em>
ie.Navigate("http://www.autohotkey.net/~Lexikos/AutoHotkey_L/")
</pre>

</body>
</html>
